// 云函数入口文件
const cloud = require('wx-server-sdk')
const got = require('got')

cloud.init()

// 云函数入口函数
exports.main = async(event, context) => {
    //event就是云函数里面data的值 event.a
    let postResponse = await got('http://dlhtx.zicp.vip:3000/wx/addMsg', { 
      method: 'post', //post请求
      headers: {
        'Content-Type': 'application/json' 
      },
      body: JSON.stringify({ //把json数据（对象）解析成字符串
        commitName:event.commitName,
        avatar:event.avatar,
        commitBody:event.commitBody
      })
    })
    return postResponse.body //返回数据
}